*** Settings ***
Test Setup        common_test_setup    @{crm_drivermanage_menu}
Test Teardown     Run Keyword If Test Failed    common_test_teardown
Resource          ../../resource/custommanage/drivermanage.txt
Resource          ../../testdata/${testenv}/custommanage/drivermanage.txt
Resource          ../../resource/workflow.txt

*** Test Cases ***
driver_modify
    kw_crm_driver_modify    @{crm_driver_modify}
    @{l}=    juma_string_to_json    @{crm_driver_modify}[1]
    kw_crm_driver_search    @{l}
    common_first_row_operate    ${False}    编辑
    wait page loaded
    ${value}    Get Value new    ${loc_crm_drivermanagepage_mobile}
    Should Be Equal    ${value}    @{crm_driver_modify}[2]
    click element new    ${loc_crm_drivermanagepage_close}
    wait_modal_invisible

driver_playback
    @{t}    Copy List    ${crm_driver_playback}
    @{l1}    evaluate    list(@{t})[:-1]
    select_tabs_bar    @{t}[0]
    @{l2}=    juma_string_to_json    @{t}[3]
    kw_crm_driver_search    @{l2}
    ${count}    Get Table Element Text    1    12
    kw_crm_driver_playback    @{l1}
    ${count2}    Get Table Element Text    1    12
    ${new_playback}    Get Table Element Text    1    13
    run keyword if    not "${count}".strip()    Should Contain    ${new_playback}    @{t}[-1]
    ${count2-1}    evaluate    ${count2}-1
    Should Be Equal As Integers    ${count}    ${count2-1}

driver_eliminate
    @{t}    Copy List    ${crm_driver_eliminate}
    kw_crm_driver_eliminate    @{t}
    ${resultnum}    get_table_result_count
    Should Be Equal As Integers    ${resultnum}    0
    select_tabs_bar    已淘汰
    ${resultnum2}    get_table_result_count
    Should Be Equal As Integers    ${resultnum2}    1
    common_first_row_operate    ${False}    淘汰原因
    Element Text Should Be New    ${loc_crm_drivermanagepage_close_reason_text}    @{t}[-1]
    click button new    ${modal_button1}
    wait_modal_invisible

driver_eliminate_recover
    kw_crm_driver_eliminate_recover    @{crm_driver_eliminate}[1]
    ${resultnum}    get_table_result_count
    Should Be Equal As Integers    ${resultnum}    0
    select_tabs_bar    已签约
    ${resultnum2}    get_table_result_count
    Should Be Equal As Integers    ${resultnum2}    1

driver_sign
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    Insert Into List    ${crm_driver_sign}    1    ${filepath}
    kw_crm_driver_sign    @{crm_driver_sign}
    comment    需要去走审批流程
    @{rs}    Query    SELECT contract_number FROM crm.`contract` t1 join crm.customer_info t2 on t2.customer_id = t1.customer_id WHERE t1.part_b = 'autotest_签约' and contract_status = 2;
    Click Menu Into Page    @{workflow_menu}
    kw_workflow_approve    @{rs}[-1]    同意    可以同意    同意    可以同意
    Click Menu Into Page    @{crm_drivermanage_menu}
    comment    需要去走审批流程

driver_file
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    ${date}=    Get Current Date    result_format=%Y-%m-%d
    kw_crm_driver_file    @{crm_driver_file}[0]    @{crm_driver_file}[1]    ${date}    ${filepath}    @{crm_driver_file}[2]    @{crm_driver_file}[3]
    comment    需要去合同中检查归档状态
